import random
import numpy as np

# 用于产生上班人员随机需求进行测试
# -1为不上，0为可上，1为AOC早班，2为AOC航后，3为AOC夜班
def RandomFun(n):
    # all_person = [
    #       {0: [1, 2, 3, 4, 5, 6, 7]},
	# 		{1: [1, 2, 3, 4, 5, 6, 7]},
	# 		{2: [1, 2, 3, 4, 5, 6, 7]},
	# 		{3: [1, 2, 3, 4, 5, 6, 7]},
	# 		{4: [1, 2, 3, 4, 5, 6, 7]},
	# 		{5: [1, 2, 3, 4, 5, 6, 7]},
	# 		{6: [1, 2, 3, 4, 5, 6, 7]},
	# 		{7: [1, 2, 3, 4, 5, 6, 7]},
	# 		{8: [1, 2, 3, 4, 5, 6, 7]},]
    all_person = []
    for i in range(n):
        #循环随机构造n个人的个人计划
        PersonDict = {}
        # 随机出一个人一周的计划，number(-1)<=3;number(1)+number(2)+number(3)<4;number(1),number(2),number(3)>=0
        PersonPlan = []
        while 1:
            RandomNum = random.randint(-1,3)
            if RandomNum == -1 and PersonPlan.count(RandomNum) < 3:
                PersonPlan.append(RandomNum)
            if RandomNum == 1 and PersonPlan.count(1) + PersonPlan.count(2) + PersonPlan.count(3) < 4:
                PersonPlan.append(RandomNum)
            if RandomNum == 2 and PersonPlan.count(1) + PersonPlan.count(2) + PersonPlan.count(3) < 4:
                PersonPlan.append(RandomNum)
            if RandomNum == 3 and PersonPlan.count(1) + PersonPlan.count(2) + PersonPlan.count(3) < 4:
                PersonPlan.append(RandomNum)
            if RandomNum == 0:
                PersonPlan.append(RandomNum)
            if len(PersonPlan) == 7:
                break
        # 当前已得到了一个人的计划，开始构造
        PersonDict[i] = PersonPlan
        all_person.append(PersonDict)
    return all_person